// pages/qualityControl/controlRecord/detail/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    startTime:"",
    endTime:'',
    code:'',
    qcItemCategory:'',
    qcPeriod:'',
    allList:[],
    title:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const eventChannel = this.getOpenerEventChannel();
		// 监听 index页面定义的toHome 事件
		eventChannel.on('toredcord', (res) => {
      this.setData({
        code:res.code,
        endTime:res.endTime,
        startTime:res.startTime,
        qcPeriod:res.item.qcPeriod,
        qcItemCategory:res.item.qcItemCategory
      })
      this.getRecordList()
			console.log(res,'页面传值') 
		})
  },
  getRecordList(){
    let self = this
    let condition = {code:self.data.code,startTime:self.data.startTime,endTime:self.data.endTime,qcPeriod:self.data.qcPeriod,qcItemCategory:self.data.qcItemCategory}
    self
    .axios
    .custom("QualityControlList", "getRecord", condition)
    .then(function (response) {
      let allData = response.data.data;
      let title = response.data.data.slice(0,2)
      console.log(allData)
      let elseData = allData.slice(2,allData.length)
      self.setData({
        allList:elseData,
        title:title
      })
      console.log(elseData)
      console.log(response)
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})